package pcjavanet.mobilesell.service;

import java.util.List;

import pcjavanet.mobilesell.model.Unit; 
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.UnitExample;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.model.QryTerm;
import pcjavanet.mobilesell.persistence.UnitMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class UnitService {


  @Autowired
  private  UnitMapper unitMapper;


  public int  insert( Unit unit ) throws Exception{
	return unitMapper.insert (unit);
  }


  public Unit  selectByPrimaryKey( Unit  bean ) {
 	int dbid = bean.getDbid();
	Unit unit = unitMapper.selectByPrimaryKey( dbid );
	return unit ;
  }


  public int  updateByPrimaryKeySelective( Unit unit ) throws Exception{
	return unitMapper.updateByPrimaryKeySelective( unit );
  }


  public int  deleteByPrimaryKey( Unit  bean ) throws Exception{
 	int dbid = bean.getDbid();
	return unitMapper.deleteByPrimaryKey( dbid );
  }


  public List<Unit>  selectByExample( Unit unit ) throws Exception{
    UnitExample example = new UnitExample();
	return unitMapper.selectByExample( example );
  }

  public List<Unit>  getOnePageBeans( QryCondition condition , PageBean pageBean ) throws Exception{
    UnitExample example = new UnitExample();
    ServiceUtil.dealCriteria( condition,  example.createCriteria() );
	List<Unit> ls=unitMapper.getOnePageBeans( example , pageBean );
//begin
	if ( ls.size() > 0 ) {
	}
//end
	return ls;
  }

  public int getTotalRecords( QryCondition condition , PageBean pageBean ) throws Exception{
    UnitExample example = new UnitExample();
    ServiceUtil.dealCriteria( condition,  example.createCriteria() );
	return unitMapper.getTotalRecords( example , pageBean );
  }

  public int countByExample( Unit unit , PageBean pageBean ){
    UnitExample example = new UnitExample();
	return unitMapper.countByExample( example );
  }
  public List<Unit> selectByExamplePage( Unit unit , PageBean pageBean ){
  UnitExample example = new UnitExample();
	return unitMapper.selectByExamplePage( example , pageBean );
  }

}
